package com.zfast.spring5.controller;

import com.zfast.spring5.Integration.UserService;
import com.zfast.spring5.model.User;
import com.zfast.spring5.repository.UserRepository;
import lombok.SneakyThrows;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @author zgn
 * @Description: HomeController
 * @date 2022/3/3 0003
 */
@Controller
@RequestMapping("/test")
public class TestController {
    @Resource
    UserRepository userRepository;

    @Resource
    UserService userService;

    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @GetMapping("/999")
    public String home() {
        return "home";
    }

    @GetMapping("/test")
    public String 测试Security页面() {
        List<User> all = userRepository.findAll();
        return "home";
    }

    @SneakyThrows
    @GetMapping("Integration")
    public String 测试Integration集成队列() {
        User user = User.builder().loginName("zgn").name("zgn").id("test001")
                .password("123").createTime(sdf.parse("2019-01-03 10:59:27")).state("1")
                .build();
        userService.saveUser(user);
        return "home";
    }
}
